All Questions
Tagged with bitwiseprogramming-challenge
24 questions
2votes
1answer
1kviews
LeetCode: Sum of Two Integers C#
https://leetcode.com/problems/sum-of-two-integers/ Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example 1: Input: a = 1, b = 2 Output: ...
4votes
2answers
378views
Find out whether number is of Power of Two
The task is taken from leetcode Given an integer, write a function to determine if it is a power of two. Example 1: Input: 1 Output: true Explanation: 20 = 1 Example 2: ...
3votes
1answer
439views
Division without using division, multiplication, or modulus operators
The task Implement division of two positive integers without using the division, multiplication, or modulus operators. Return the quotient as an integer, ignoring the remainder. My solution <...
4votes
1answer
7kviews
Hamming Distance in Python
I was solving this Leetcode challenge about Hamming Distance. Would love feedback on my syntax and code style. Here's the challenge description: The Hamming distance between two integers is the ...
4votes
5answers
6kviews
Largest binary gap
I took a task from Codility to find longest sequence of zeros in binary representation of an integer. For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The ...
3votes
1answer
7kviews
Hackerrank "Strings: Making Anagrams" Javascript Solution
This is the original problem : Input Format The first line contains a single string, a. The second line contains a single string, b. Constraints 1<= |a|,|b| <= 10^4 It ...
3votes
2answers
1kviews
Codility “PermMissingElem” Solution
This is my solution to the PermMissingElem problem, I wonder what can be improved? Expected worst case time complexity is O(N), but the performance test shows that it's O(N) or O(N * log(N)), which I ...
6votes
2answers
5kviews
Codility binary gap solution
This is how I solved the binary gap problem: Find longest sequence of zeros, bounded by ones, in binary representation of an integer I wonder how does it fare against solutions such as ones appeared ...
2votes
0answers
3kviews
Hackerrank: Max Score
Problem statement Consider an n-element sequence of integers, A = {a0, a0, ..., an-1}. We want to perform \$n\$ operations on \$A\$, where each operation is defined by the following sequence of ...
11votes
4answers
27kviews
Find the binary gap of a number N
For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 1000010001 and contains two binary gaps: one of length 4 and one of ...
4votes
1answer
2kviews
Hackerrank Sum vs XoR
I'm in the process of improving my coding style and performance hence I decided to delve into bit manipulation on Hackerrank. I thought the question was straight forward but on large input, my ...
8votes
2answers
3kviews
Maximize result of bitwise AND
This was the problem from "30 Days of Code" on Hackerrank: Given set \$S = \lbrace{1,2,3,\dots,N}\rbrace\$, find two integers \$A\$ and \$B\$ (where \$A \lt B\$), from set \$S\$ such that the value ...
12votes
3answers
6kviews
Codility binary gap solution using regex
Below is the code I implemented to solve the binary gap problem: Find longest sequence of zeros, bounded by ones, in binary representation of an integer. However, it seems to be different from the ...
6votes
3answers
9kviews
Printing longest sequence of zeroes
I am doing a coding exercise in codility and I came across this question: A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ...
3votes
1answer
88views
Testing for divisibility of numbers - follow-up
(Here is the follow up question) I had another go at trying to speed up my program described in my previous question. JS1's answer was particulary helpful and now my code is only about 20% slower ...